# -*- mode: snippet -*-
# name: list files/subdirs with os.listdir and fnmatch.fnmatch
# key: list_files_fnmatch@os.fnmatch
# contributor: Shuguang Sun
# --
def ${1:lsfiles}(path, pattern = "*.py"):
    for file in os.listdir(path):
        if fnmatch.fnmatch(file, pattern):
            if os.path.isfile(os.path.join(path, file)):
                yield file

for file in $1(${2:"."}, pattern = ${3:"*.py"}):
    print(file)
